package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.util.SerialNumberGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysInitialRoleMapper;
import com.ruoyi.system.domain.SysInitialRole;
import com.ruoyi.system.service.ISysInitialRoleService;

/**
 * 初始角色Service业务层处理
 * 
 * @author zjf
 * @date 2025-11-06
 */
@Service
public class SysInitialRoleServiceImpl implements ISysInitialRoleService 
{
    @Autowired
    private SysInitialRoleMapper sysInitialRoleMapper;

    /**
     * 查询初始角色
     * 
     * @param initialId 初始角色主键
     * @return 初始角色
     */
    @Override
    public SysInitialRole selectSysInitialRoleByInitialId(Long initialId)
    {
        return sysInitialRoleMapper.selectSysInitialRoleByInitialId(initialId);
    }

    /**
     * 查询初始角色列表
     * 
     * @param sysInitialRole 初始角色
     * @return 初始角色
     */
    @Override
    public List<SysInitialRole> selectSysInitialRoleList(SysInitialRole sysInitialRole)
    {
        return sysInitialRoleMapper.selectSysInitialRoleList(sysInitialRole);
    }

    /**
     * 新增初始角色
     * 
     * @param sysInitialRole 初始角色
     * @return 结果
     */
    @Override
    public int insertSysInitialRole(SysInitialRole sysInitialRole)
    {
        sysInitialRole.setCreateTime(DateUtils.getNowDate());
        sysInitialRole.setInitialStatus("1");
        sysInitialRole.setUserCount("0");
        sysInitialRole.setRoleId(Long.parseLong(SerialNumberGenerator.getNextSerialNumber()));
        return sysInitialRoleMapper.insertSysInitialRole(sysInitialRole);
    }

    /**
     * 修改初始角色
     * 
     * @param sysInitialRole 初始角色
     * @return 结果
     */
    @Override
    public int updateSysInitialRole(SysInitialRole sysInitialRole)
    {
        return sysInitialRoleMapper.updateSysInitialRole(sysInitialRole);
    }

    /**
     * 批量删除初始角色
     * 
     * @param initialIds 需要删除的初始角色主键
     * @return 结果
     */
    @Override
    public int deleteSysInitialRoleByInitialIds(Long[] initialIds)
    {
        return sysInitialRoleMapper.deleteSysInitialRoleByInitialIds(initialIds);
    }

    /**
     * 删除初始角色信息
     * 
     * @param initialId 初始角色主键
     * @return 结果
     */
    @Override
    public int deleteSysInitialRoleByInitialId(Long initialId)
    {
        return sysInitialRoleMapper.deleteSysInitialRoleByInitialId(initialId);
    }

    /**
     * 修改角色状态
     * @param initialId
     * @param initialStatus
     * @return
     */
    @Override
    public int changeRoleStatus(Long initialId, String initialStatus) {
        SysInitialRole sysInitialRole = new SysInitialRole();
        sysInitialRole.setInitialId(initialId);
        sysInitialRole.setInitialStatus(initialStatus);
        return sysInitialRoleMapper.updateSysInitialRole(sysInitialRole);
    }
}
